package LC;

/**
 * @ClassName Lc26
 * @Description: TODO
 * @Author hl
 * @Date 2020/9/13
 * @Version V1.0
 **/
public class Lc26 {
    public int removeDuplicates(int[] nums) {
        if(nums==null) {
            return 0;
        }
        if(nums.length==0||nums.length==1){
            return nums.length;
        }

        int pre=nums[0];
        int index=1;
        for(int i=1;i<nums.length;i++){
            if(pre!=nums[i]){
                nums[index++]=nums[i];
                pre=nums[i];
            }
        }
        return index;
    }
}
